package com.hs.pre.sys.validate;

import java.util.List;
import java.util.Map;

import com.hs.HsBase;
import com.hs.core.db.DBOperator;
import com.hs.core.db.DatabaseConnection;
import com.hs.pre.model.UserBean;

public class ValidateDao {
	
	public UserBean findBean(String loginId,String pwd) 
	{

		String sql = (String) HsBase.getAnsiSqlMap().get("pre_user.loginBean");
		DBOperator dbo = null;
		try {
			dbo = DatabaseConnection.getDBOperator();
		
		if(dbo == null)
			return null;
		List list02 = dbo.select(sql, new Object[]{loginId,pwd});
		if(!list02.isEmpty())
		{

			Map map = (Map)list02.get(0);
			UserBean userBean = new UserBean();
			userBean.setUserId((Long)map.get("userId"));
			userBean.setLoginId((String)map.get("loginId"));
			userBean.setUserName((String)map.get("userName"));
			userBean.setIsAdmin((Integer)map.get("isAdmin"));
			if(map.get("isDelete") != null )
				userBean.setIsDelete((Integer)map.get("isDelete") );
			userBean.setEmail((String)map.get("email"));
			return userBean;
		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
